package cn.xiaoming.car.server.content.controller;

import cn.xiaoming.car.pojo.car.pojo.vo.CarVO;
import cn.xiaoming.car.server.content.dao.persist.mapper.ParameterMapper;
import cn.xiaoming.car.server.jsonresult.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.validator.constraints.Range;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/content/parameter")
@Validated
public class ParameterController {
    @Autowired
    ParameterMapper parameterMapper;


    @GetMapping("/{id:[0-9]+}")
    public JsonResult getCarById(@PathVariable @Range(min = 1, message = "获取标签详情失败，请提交合法的ID值！")Long id){
        log.debug("开始处理【根据ID查询车辆参数】的请求，参数：{}", id);
        CarVO car =parameterMapper.getCarById(id);
        return JsonResult.ok(car);
    }
}
